import { StoreSvr } from './../../services/store';
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
    selector: 'device-type',
    template: `
        <div class="type flex-column">
            <div (click)="changeName('addDevice')" class="title bg-darkgray">
                <i class="material-icons icon">navigate_before</i>
                <span>选择设备类型</span>
            </div>
            <div class="list">
                <section (click)="saveDeviceType()">
                    <img class="img-printer" src="./assets/img/devtype-receipt-printer.png">
                    <div class="flex-column">
                        <span class="device-type-name">出品打印机</span>
                        <span class="text-desc">用来打印出品小票的打印机</span>
                    </div>
                </section>
            </div>
        </div>
    `,
    styleUrls: ['./printer.component.scss']
})

export class DeviceTypeComponent{
    @Output()
    changePageName: EventEmitter<any> = new EventEmitter<any>();
    constructor( private storeSvr:StoreSvr ){}

    changeName(name){
        this.changePageName.emit(name);
    }

    saveDeviceType(){
        let ele = document.querySelector('.device-type-name');
        let type = ele.innerHTML;
        this.storeSvr.setDeviceType(type);
        this.changeName('interfaceType')
    }
}